#include "DefaultUtils.h"

int errexit(const char* format, ...)
{
    va_list args;
    va_start(args,format);
    vfprintf(stderr,format,args);
    va_end(args);
    exit(1);
}

char* gotonotblank(char* cBase)
{
    int i=0;
    while(1)
    {
        if(cBase[i]=='\0')
            return NULL;
        if(cBase[i]==' ')
           ++i;
        else
            break;
    }
    return (cBase+i);
}

int getposofchar(char* cBase,char c)
{
    int i =0;
    while(cBase[i]!=c)
      ++i;
    return i;
}

int getposofnotcharorc(char* cBase,char c)
{
    int i=0;
    while(1)
    {
        if(((cBase[i]>='a'&&cBase[i]<='z'))||(cBase[i]>='A'&&cBase[i]<='Z'))
            ++i;
        else if(cBase[i]==c)
            ++i;
        else
            break;
    }
    return i;
}

ssize_t WriteBuf(int fd,const char* buf,size_t _n)
{
    #ifdef SYS_WIN32

    #else // SYS_LINUX
    return write(fd,buf,_n);
    #endif
}

ssize_t ReadBuf (int __fd, void *__buf, size_t __nbytes)
{
    #ifdef SYS_WIN32

    #else // SYS_LINUX
    return read(__fd,__buf,__nbytes);
    #endif
}
